<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);

chdir("/home/cm/public_html/crons/");
include('../config.php');

$log = new Logging();

$log->lfile('../logs/unexpended_prepaid_range_' . date('Y_m_d') . '.log');
$log->lwrite('Start');

$_REQUEST['period'] = str_pad(date("m"), 2, "0", STR_PAD_LEFT) . "/" . date("Y");
include (PATH_TO_MODULES . "reports/unexpended_range.php");

$GLOBALS['template_data']['is_mail'] = 1;
$GLOBALS['smarty']->template_dir = PATH_TO_TEMPLATES . 'reports/';
$GLOBALS['smarty']->assign("data", $GLOBALS['template_data']);
$message = $GLOBALS['smarty']->fetch('unexpended_range.tpl');

if (!empty($message)) {

    $notify_obj = new notify_obj();
    $recipients_emails = array();
    $recipients_emails[] = 'projector@alfac.sk';
    
    $subject = "CM: Unexpended prepaid range";
    
    $send_result = $notify_obj->send($recipients_emails, $message, $subject);
    if (error_obj::isError($send_result))
        $log->lwrite('Nepodarilo sa odoslat emaily');
}


$log->lwrite('Stop');
$log->lwrite('------------------------------------------');

$log->lclose();
?>
